package com.zzmcc.wechat.oauth;

import java.util.Map;

import com.alibaba.fastjson.JSON;
import com.zzmcc.wechat.util.HttpKit;
import org.smart4j.framework.util.JsonUtil;

@SuppressWarnings("unchecked")
public class Menu {

    /**
     * 创建菜单
     */
	public boolean createMenu(String accessToken,String params)  {

        String jsonStr = HttpKit.post("https://api.weixin.qq.com/cgi-bin/menu/create?access_token=" + accessToken, params);
        Map<String, Object> map = JSON.parseObject(jsonStr,Map.class);
        return "0".equals(map.get("errcode").toString());

    }
    
    /**
     * 查询菜单
     */
    public Map<String, Object> getMenuInfo(String accessToken) {

        String jsonStr = HttpKit.get("https://api.weixin.qq.com/cgi-bin/menu/get?access_token=" + accessToken);
        Map<String, Object> map = JSON.parseObject(jsonStr, Map.class);
        return map;



    }
    
    /**
     * 删除自定义菜单
     */
    public boolean deleteMenu(String accessToken)   {
        String jsonStr = HttpKit.get("https://api.weixin.qq.com/cgi-bin/menu/delete?access_token=" + accessToken);
        Map<String, Object> map = JSON.parseObject(jsonStr, Map.class);
        return "0".equals(map.get("errcode").toString());
    }


}
